Skip to content

perf(parser): avoid re-allocating when parsing import stmt#20666

Merged
graphite-app[bot] merged 1 commit intomainfrom
c/03-23-perf_parser_avoid_re-allocating_when_parsing_import_stmt
Mar 24, 2026
Merged

perf(parser): avoid re-allocating when parsing import stmt#20666
graphite-app[bot] merged 1 commit intomainfrom
c/03-23-perf_parser_avoid_re-allocating_when_parsing_import_stmt

Conversation

@camc314
Copy link
Copy Markdown
Contributor

@camc314 camc314 commented Mar 23, 2026

No description provided.

@camc314 camc314 marked this pull request as ready for review March 23, 2026 21:32
Copilot AI review requested due to automatic review settings March 23, 2026 21:32
Copy link
Copy Markdown
Contributor Author

camc314 commented Mar 23, 2026


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent changes, fast-track this PR to the front of the merge queue

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@github-actions github-actions bot added A-parser Area - Parser C-performance Category - Solution not expected to change functional behavior, only performance labels Mar 23, 2026
@camc314 camc314 force-pushed the c/03-23-perf_parser_avoid_re-allocating_when_parsing_import_stmt branch from b7bfa7f to 690724a Compare March 23, 2026 21:33
@camc314 camc314 force-pushed the c/03-23-perf_parser_avoid_vec_clone branch from 2d352a9 to 0373c67 Compare March 23, 2026 21:33
@camc314 camc314 force-pushed the c/03-23-perf_parser_avoid_re-allocating_when_parsing_import_stmt branch from 690724a to fefedb6 Compare March 23, 2026 21:34
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Improves parser performance for import declarations by avoiding an intermediate allocation when parsing named import specifiers, reusing an existing arena Vec instead.

Changes:

  • Replaced parse_import_specifiers (returning a new Vec) with parse_import_specifiers_into that appends directly into an existing specifiers list.
  • Added parse_delimited_list_into helper to parse delimited lists into an existing arena Vec, avoiding re-allocation.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
crates/oxc_parser/src/js/module.rs Switches import-specifier parsing to append into an existing specifiers vec to avoid creating a temporary vec.
crates/oxc_parser/src/cursor.rs Introduces parse_delimited_list_into to support parsing directly into an existing list.

@camc314 camc314 force-pushed the c/03-23-perf_parser_avoid_re-allocating_when_parsing_import_stmt branch from fefedb6 to 2cb0cb3 Compare March 23, 2026 21:36
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Mar 23, 2026

Merging this PR will not alter performance

✅ 53 untouched benchmarks
⏩ 3 skipped benchmarks1


Comparing c/03-23-perf_parser_avoid_re-allocating_when_parsing_import_stmt (2cb0cb3) with c/03-23-perf_parser_avoid_vec_clone (0373c67)

Open in CodSpeed

Footnotes

  1. 3 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@graphite-app graphite-app bot added the 0-merge Merge with Graphite Merge Queue label Mar 24, 2026
@graphite-app
Copy link
Copy Markdown
Contributor

graphite-app bot commented Mar 24, 2026

Merge activity

@graphite-app graphite-app bot force-pushed the c/03-23-perf_parser_avoid_vec_clone branch from 0373c67 to 2b2794b Compare March 24, 2026 04:01
@graphite-app graphite-app bot force-pushed the c/03-23-perf_parser_avoid_re-allocating_when_parsing_import_stmt branch from 2cb0cb3 to ad58dd7 Compare March 24, 2026 04:01
Base automatically changed from c/03-23-perf_parser_avoid_vec_clone to main March 24, 2026 04:04
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Mar 24, 2026
@graphite-app graphite-app bot merged commit ad58dd7 into main Mar 24, 2026
28 checks passed
@graphite-app graphite-app bot deleted the c/03-23-perf_parser_avoid_re-allocating_when_parsing_import_stmt branch March 24, 2026 04:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-parser Area - Parser C-performance Category - Solution not expected to change functional behavior, only performance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants